package cn.kgm.user.server.controller;

import cn.kgm.core.http.request.BaseController;
import cn.kgm.core.jackson.JsonUtil;
import cn.kgm.user.dto.entity.UserTypeDealer;
import cn.kgm.user.server.service.UserTypeDealerService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * # 技术改变自己 #
 * toC客户
 * @author Kappi
 * @date   2024-04-13 16:44:52
 */
@Slf4j
@SpringBootTest
class UserTypeDealerTestService extends BaseController {

    @Autowired
    private UserTypeDealerService userTypeDealerService;

    @Test
    void page() {
        IPage<UserTypeDealer> page = getPage();
        LambdaQueryWrapper<UserTypeDealer> wrapper = Wrappers.lambdaQuery(UserTypeDealer.builder()
                .build());
        IPage<UserTypeDealer> pages = userTypeDealerService.page(page, wrapper);
        log.info("UserTypeDealerTestService::page===>{}", JsonUtil.toJson(pages.getRecords()));
    }

    @Test
    void get() {
        Long id = 1L;
        UserTypeDealer userTypeDealer =userTypeDealerService.getById(id);
        log.info("UserTypeDealerTestService::get===>{}", JsonUtil.toJson(userTypeDealer));
    }

    @Test
    void save() {
        UserTypeDealer userTypeDealer = UserTypeDealer.builder()
                .build();
            userTypeDealerService.save(userTypeDealer);
        log.info("UserTypeDealerTestService::save===>{}", JsonUtil.toJson(userTypeDealer));
    }

    @Test
    void update() {
        UserTypeDealer userTypeDealer = UserTypeDealer.builder()
                .build();
            userTypeDealerService.updateById(userTypeDealer);
        log.info("UserTypeDealerTestService::update===>{}", JsonUtil.toJson(userTypeDealer));
    }

    @Test
    void delete() {
        Long[] ids = new Long[]{0L};
            userTypeDealerService.update(Wrappers.<UserTypeDealer>lambdaUpdate()
                .set(UserTypeDealer::getIsDel, true)
                .in(UserTypeDealer::getId, ids));
        log.info("UserTypeDealerTestService::delete===>{}", JsonUtil.toJson(ids));
    }
}
